package com.xhh.nphm.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xhh.nphm.system.domain.SensitiveInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *  敏感信息 dao
 */
@Repository
public interface SensitiveInfoDao extends BaseMapper<SensitiveInfo> {
    /**
     * 通过pkid获取一条敏感信息
     *
     * @param pkId 来电记录id
     * @return 敏感信息
     */
    @Results(id = "sensitive_info",value = {
            @Result(column = "id",property = "id"),
            @Result(column = "telGetDealPk",property = "telGetDealPk"),
            @Result(column = "id",property = "details",javaType= List.class ,many = @Many(select = "com.xhh.nphm.system.mapper.SensitiveInfoDetailDao.findDetailsBySensitiveId")),
    })
    @Select("SELECT id,telGetDealPk FROM tm_sensitive_info WHERE telGetDealPk = #{0}")
    SensitiveInfo findOneByPkId(Integer pkId);

    /**
     * 通过id获取一条敏感信息
     *
     * @param id 敏感信息主键id
     * @return 敏感信息
     */
    @ResultMap(value = "sensitive_info")
    @Select("SELECT id,telGetDealPk FROM tm_sensitive_info WHERE id = #{0}")
    SensitiveInfo findOneById(Integer id);
}
